import React ,{lazy} from "react"
import MainLayout from "../components/mainlayout"
import {Navigate} from "react-router-dom"

const Home = lazy(()=>import("../view/home"))
const Userlist = lazy(()=>import("../view/userlist"))
const Rotelist = lazy(()=>import("../view/rotelist"))
const Upload = lazy(()=>import("../view/upload"))
const Set = lazy(()=>import("../view/set"))
const Login = lazy(()=>import("../view/login"))
const Sign = lazy(()=>import("../view/sign"))

export interface RoutesType {
    path:string,
    element?:JSX.Element,
    meta:{
        title:string,
        auth?:string[]
    },
    hidden?:boolean,
    children?:RoutesType[]
}


export const ROUTES_LIST:RoutesType[] = [
        {
            path:"/home",
            meta:{
                title:"首页"
            },
            element:(<MainLayout><Home></Home></MainLayout>)
        },
        {
            path:"/",
            meta:{
                title:"重定向"
            },
            element :(<Navigate to="/login"></Navigate>),
            hidden:true
        },
        {
            path:"/list",
            meta:{
                title:"分类列表"
            },
            children:[
                {
                    path:"/userlist",
                    meta:{
                        title:"用户列表"
                    },
                    element:(<MainLayout><Userlist></Userlist></MainLayout>)
                },{
                    path:'/rotelist',
                    meta:{
                        title:"角色列表"
                    },
                    element:(<MainLayout><Rotelist></Rotelist></MainLayout>)
                }
            ]
        },{
            path:"/upload",
            meta:{
                title:"上传"
            },
            element:(<MainLayout><Upload></Upload></MainLayout>)
        },{
            path:"/set",
            meta:{
                title:"设置",
            },
            element:(<MainLayout><Set></Set></MainLayout>)
        },{
            path:"/login",
            meta:{
                title:"登录",
            },
            element:(<Login></Login>),
            hidden:true
        }
        ,{
            path:"/sign",
            meta:{
                title:"注册",
            },
            element:(<Sign></Sign>),
            hidden:true
        }
]